package com.hong.controller.v2;

import com.hong.model.InMessage;
import com.hong.model.OutMessage;
import com.hong.service.WebSocketService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.stereotype.Controller;

/**
 * @Author csh
 * @Description
 * @Date 2018/9/13 22:06
 */
@Controller
public class V2GameInfoController {

    @Autowired
    private WebSocketService ws;
    /**
     * MessageMapping 跟requestMapping类似但是messageMapping是针对websocket
     * SendTo 发送给指定的客户
     * */
    @MessageMapping("/v2/chat")
    public void gameInfo(InMessage inMessage){
        ws.sendTopicMessage("/topic/game_rank",inMessage);
    }
}
